package com.hdoit.kylin.web.baseInfo.modelconfig;

import com.tennetcn.common.enums.ManageContainer;
import com.tennetcn.common.enums.regular.RegularExpressions;
import com.tennetcn.component.attribute.DisplayNameAttribute;
import com.tennetcn.component.attribute.DropDownListAttribute;
import com.tennetcn.component.attribute.RegularExpressionAttribute;
import com.tennetcn.component.attribute.RemoteAttribute;
import com.tennetcn.component.attribute.RequiredAttribute;
import com.tennetcn.component.attribute.base.ModelMetadataAttributeConfiguration;
import com.tennetcn.web.cbase.providers.SexProvider;

/**
 * @author      lufu
 * @email       
 * @createtime  2017年07月27日 16:53:08
 * @comment
 */
public class OperationConfig extends ModelMetadataAttributeConfiguration{
    public OperationConfig(){
        this.setProperty("operationName")
            .hasAttribute(new DisplayNameAttribute("用户名称"))
            .hasAttribute(new RequiredAttribute("用户名称为必填项"));

        RemoteAttribute employeeAccountRemoteAttribute=new RemoteAttribute();
		employeeAccountRemoteAttribute.setAdditionalfields("*.employeeAccount,*.employeeId");
		employeeAccountRemoteAttribute.setErrorMessage("已经存在相应的账号");
		employeeAccountRemoteAttribute.setRemoteUrl(ManageContainer.VIRTUALPATH+"/admin/baseInfo/operation/checkAccount");
        this.setProperty("employeeAccount")
            .hasAttribute(new DisplayNameAttribute("账号"))
            .hasAttribute(new RequiredAttribute("账号为必填项"))
            .hasAttribute(employeeAccountRemoteAttribute);

        this.setProperty("sex")
            .hasAttribute(new DisplayNameAttribute("性别"))
            .hasAttribute(new DropDownListAttribute(new SexProvider()));

        this.setProperty("mobile")
            .hasAttribute(new DisplayNameAttribute("手机"))
            .hasAttribute(new RegularExpressionAttribute(RegularExpressions.mobile));

        this.setProperty("email")
            .hasAttribute(new DisplayNameAttribute("email"))
            .hasAttribute(new RegularExpressionAttribute(RegularExpressions.email));

        this.setProperty("comments")
            .hasAttribute(new DisplayNameAttribute("描述"));

    }
}